//
//  ShareCopy.swift
//  BMWShareSDK
//
//  Created by Li Shengbing, (Shengbing.Li@partner.bmw.com) on 2019/8/12.
//  Copyright © 2019年 Li Shengbing, (Shengbing.Li@partner.bmw.com). All rights reserved.
//

import UIKit

class ShareCopy: NSObject {

    override init() {
        super.init()
    }
    
    static func share(text: String) {
        UIPasteboard.general.string = text
        
        var resultDescription: String = ""
        if UIPasteboard.general.string == text {
            resultDescription = BMWNSLocalizedString.localizedString("SHARE_COPY_CALLBACK_SUCCESS", comment: "Link copied to clipboard")
        }else {
            resultDescription = BMWNSLocalizedString.localizedString("SHARE_COPY_CALLBACK_FAIL", comment: "Failed to copy")
        }
        /// Handle completBlock async callback.
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.05) {
            if BMWShareManager.shareComplete != nil {
                BMWShareManager.shareComplete!(resultDescription)
            }
        }
    }
}
